// 询价服务，依赖于 PricingChannel 接口
class PriceServiceGood {
    private _pricingChannelGood: PricingChannelGood

    set pricingChannelGood(value: PricingChannelGood) {
        this._pricingChannelGood = value;
    }

    constructor(pricingChannelGood: PricingChannelGood) {
        this._pricingChannelGood = pricingChannelGood;
    }

    getPrice(productId: string): number {
        return this._pricingChannelGood.getPrice(productId);
    }
}

// 定义询价渠道接口
interface PricingChannelGood {
    getName(): string;
    getPrice(productId: string): number;
}

// 各个询价渠道的具体实现
class TongChengChannelGood implements PricingChannelGood {
    getName(): string {
        return "同程";
    }

    getPrice(productId: string): number {
        // 实际的价格获取逻辑
        // ...
        return 100; // 假设获取的价格为 100 元
    }
}

class XieChengChannelGood implements PricingChannelGood {
    getName(): string {
        return "携程";
    }

    getPrice(productId: string): number {
        // 实际的价格获取逻辑
        // ...
        return 120; // 假设获取的价格为 120 元
    }
}
class FeiZhuChannelGood implements PricingChannelGood {
    getName(): string {
        return "携程";
    }

    getPrice(productId: string): number {
        // 实际的价格获取逻辑
        // ...
        return 145; // 假设获取的价格为 120 元
    }
}

function main() {
    const priceServiceGood = new PriceServiceGood(new XieChengChannelGood());
    console.log(priceServiceGood.getPrice("productId12323"));

    priceServiceGood.pricingChannelGood = new FeiZhuChannelGood()
    console.log(priceServiceGood.getPrice("productId12323"));

    priceServiceGood.pricingChannelGood = new TongChengChannelGood()
    console.log(priceServiceGood.getPrice("productId12323"));

}

main()